package controler;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;


public class InserirPacote {
	
	public static void insert(String preco, String partida, String destino, String ida,
			String volta, String classificacaohotel, String nomehotel, String companhiaaerea)
	{
		try {
			Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
            Connection conn = DriverManager.getConnection("jdbc:derby:./bd;create=true");
            Statement command = conn.createStatement();
            try {
            	command.executeUpdate(
						"INSERT INTO pacotes VALUES("+
						// [Davi] TODO: arrumar a capta��o de valores de cadastrarpacote.jsp
						//			aonde est�o os arquivos Servlets?
						/*"id INT IDENTITY (1, 1) NOT NULL,"+ 
						"preco DECIMAL, "+
						"partida varchar(1000), "+
						"destino decimal, "+
						"ida varchar(1000), "+
						"volta VARCHAR(1000), "+
						"classificacaohotel INT, "+
						"nomehotel VARCHAR(1000), "+
						"companhiaaereaid INT, "+*/
						")");
				
				System.out.println("Table pacotes created succesfully");
            }
            catch (SQLException e) {
            	System.out.println("Can't insert this values into table 'pacotes': " + e.getMessage());
            }
		}
		catch (SQLException e){
			System.out.println("Can't connect to the derby database: " + e.getMessage());
		}
		catch (ClassNotFoundException e) {
			System.out.println("Missing class! Check your CLASSPATH");
		}
	}

}
